package src.test2;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class ThreadClient1 extends Thread{
	
	
	public void run()
	{
		 Socket comm = null;
		    InputStream is = null;
		 
		    try
		    {
		    	
		      comm = new Socket("localhost",18888); 
		      comm.getOutputStream().write("Bonjour je suis le client 1\n\r".getBytes());
		      is = comm.getInputStream();
		      int c;
		      while((c = is.read()) != -1){
		    	 
		        System.out.write(c);
		      }
			
		    }
		    catch(Exception e)
		    {
		      System.err.println("Exception " + e.toString());
		    }
		    finally
		    {
		      if (is!=null)
				try {
					is.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		      if (comm!=null)
				try {
					comm.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		    }
		  }

}
